package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.home.info;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo.UserPermission;

import com.gwtext.client.data.SimpleStore;

/**
 * @author Renato Miceli
 */
public class PermissionStore extends SimpleStore {

	public PermissionStore() {
		super(new String[] { getColumnName() }, new String[][] { new String[] { "Administrator" }, new String[] { "Basic User" } });
		this.load();
	}

	public static String getColumnName() {
		return "type";
	}

	public static UserPermission getPermission(String value) {
		if (value.equals("Administrator")) {
			return UserPermission.ADMIN;
		} else if (value.equals("Basic User")) {
			return UserPermission.COMMON_USER;
		} else {
			return null;
		}
	}

	public static String getValue(UserPermission permission) {
		switch (permission) {
		case ADMIN:
			return "Administrator";
		case COMMON_USER:
			return "Basic User";
		default:
			return null;
		}
	}

}
